const USER = {
    login: function(args) {
        window.localStorage['accessToken'] = args.accessToken;
        window.localStorage['userLevel'] = args.userLevel;
        window.localStorage['mobile'] = args.mobile;
        window.localStorage['resultCode'] = args.resultCode;
        window.localStorage['tipCode'] = args.tipCode;
        window.localStorage['userName'] = args.userName;
        window.localStorage['webUserId'] = args.webUserId;
        window.localStorage['token'] = args.token;
    },
    logout: function() {
        window.localStorage.removeItem('accessToken');
        window.localStorage.removeItem('userLevel');
        window.localStorage.removeItem('mobile');
        window.localStorage.removeItem('resultCode');
        window.localStorage.removeItem('tipCode');
        window.localStorage.removeItem('userName');
        window.localStorage.removeItem('webUserId');
        window.localStorage.removeItem('token');
    },
    setObject: function(key, value) {
        try {
            window.localStorage[key] = JSON.stringify(value);
        } catch (e) {
            alert('本地储存写入错误，若为safari浏览器请关闭无痕模式浏览。');
        }
    }
};

export {
    USER
};